package com.qf.mapper2;

import com.qf.domain2.Student;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface StudentMapper2 {

    /**
     * 根据班级id查询当前班级对应的学生集合
     * @param cid
     * @return
     */

    @Select("select * from student where cid=#{cid}")
    public List<Student> findByCid(Integer cid);


    /**
     * 查询所有学生，同时查询出学生所在的班级
     * @return
     */
    @Select("SELECT s.*,cl.name cname\n" +
            "FROM student s LEFT JOIN classes cl ON s.cid=cl.`id`")
    @ResultMap("stuMap")
    public List<Student> findAll();
}
